package objexc;

public class PhoneTest {
    public static void main(String[] args) {
        Phone[] arr = new Phone[3];
        //创建手机对象
        Phone p1 = new Phone("小米",1999,"黑");
        Phone p2 = new Phone("华为",4999,"白");
        Phone p3 = new Phone("荣耀",3999,"黑");
        //把手机对象添加到数组当中
        arr[0] = p1;
        arr[1] = p2;
        arr[2] = p3;
        //获取平均价格
        int sum=0;
        for(int i=0;i<arr.length;i++){
            Phone phone=arr[i];
            sum+=phone.getPrice();
        }
        //求平均值
        int avg=sum/arr.length;
        System.out.println(avg);

    }
}
